﻿using DeviceDebugger.Model;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace DeviceDebugger.Converter
{
    class ConverterShowTaskList : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && value is StackerTasksModel && !string.IsNullOrEmpty((value as StackerTasksModel).StartLocation) && !string.IsNullOrEmpty((value as StackerTasksModel).EndLocation))
            {
                string[] startLocation = (value as StackerTasksModel).StartLocation.Split('-');
                string[] endLocation = (value as StackerTasksModel).EndLocation.Split('-');
                if (startLocation.Length > 3 && endLocation.Length > 3)
                    return startLocation[1] + "排" + startLocation[2] + "列" + startLocation[3] + "层" + "  ==>  " + endLocation[1] + "排" + endLocation[2] + "列" + endLocation[3] + "层";
                else
                    return startLocation[0] + "排" + startLocation[1] + "列" + startLocation[2] + "层" + "  ==>  " + endLocation[0] + "排" + endLocation[1] + "列" + endLocation[2] + "层";
            }
            return "暂无任务";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
